<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作用域链</title>
  </head>

  <body>

  </body>
  <script>
    /* 
    一.作用域链：根据在内部函数可以访问外部函数变量的这种机制，用链式查找决定哪些数据能被内部函数访问，
            就称作作用域链 
         1.1 “就近原则”   
    */
    var num = 10;

    function fn() { //外部函数
      var num = 20;

      function func() { //内部函数
        console.log(num); //20
      }
      func()
    }
    fn();
    console.log(num); //10
  </script>

</html>